#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 5e5+5;
int n,k,a[N],b[N],c[N],cnt;
int t[N];
#define lowbit(x) (x&(-x))
inline void add(int x,int v)
{
	for(;x<=cnt;x+=lowbit(x)) t[x] = max(t[x],v);
}
inline int ask(int x)
{
	int res = -2e9;
	for(;x;x-=lowbit(x)) res = max(res,t[x]);
	return res;
}
inline bool ok(int x)
{
	for(int i = 1;i<=cnt;i++) t[i] = -2e9;
	add(1,1);
	int p = cnt;
	for(int i = 1;i<=cnt;i++)
	{
		while(p&&b[i]+b[p]>x) p--;
		c[i] = p;
	}
	for(int i = 2;i<=n;i++)
	{
		if(b[a[i]]+b[a[1]]>x) continue;
//		int tmp = x-b[a[i]];
//		tmp = upper_bound(b+1,b+cnt+1,tmp)-b-1;
//		assert(tmp==c[a[i]]);
		int now = ask(c[a[i]]);
		add(a[i],now+1);
		if(now+1>=k) return 1;
	}
	return 0;
}
signed main()
{
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	int p = 1;
	for(int i = 1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[p]) p = i;
	}
	for(int i = p;i<=n;i++)
		b[++cnt] = a[i];
	for(int i = 1;i<p;i++)
		b[++cnt] = a[i];
	for(int i = 1;i<=n;i++) a[i] = b[i];
	sort(b+1,b+cnt+1);
	int l = b[1]+b[2],r = b[n-1]+b[n];
	cnt = unique(b+1,b+cnt+1)-b-1;
	for(int i = 1;i<=n;i++) a[i] = lower_bound(b+1,b+n+1,a[i])-b;
	int res = -1;
	while(l<=r)
	{
		int mid = (l+r)/2;
		if(ok(mid)) res = mid,r = mid-1;
		else l = mid+1;
	}
	cout<<res;
	return 0;
}

